/*
 * page1.c
 *
 *  Created on: Jan 7, 2012
 *      Author: ian
 */
#include <stdio.h>
#include <avr/io.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include <math.h>
#include <string.h>
#include <avr/pgmspace.h>
#include "backlight.h"
#include "lcd.h"
#include "pages.h"
#include "buttons.h"
#include "bar.h"
#include "em36.h"
#include "page1.h"

extern const prog_uint8_t bmp_page1[];

stBar thrBar = { 62,  89, 64, 10, 0, true,  0, 60, yellow, green, red };
stBar watBar = { 62, 111, 64, 10, 0, true, 30, 45, blue, green, red };

void PAGE_1_init(void)
{
	LCD_Bitmap( 0, 44, bmp_page1 );
	BAR_init( &thrBar );
	BAR_init( &watBar );
	LCD_Smooth_Numbers( " 0.0", 92, 132);		//38
}

void PAGE_1_clear(void)
{
	LCD_Box( 0, 44, 132, 144, black );		// blank out body
}

void PAGE_1_update(void)
{
	unsigned char tmp;

	BAR_update( &thrBar, (EM36_throttle >> 2) );
	tmp = (EM36_coolant / 2);
	if( tmp > 63 ) tmp = 63;
	BAR_update( &watBar, tmp );

	LCD_Smooth_Int( EM36_vehicleSpeed, 3, 0, 97, 44 );
	LCD_Smooth_Int( EM36_engineSpeed, 5, 0, 75, 66 );
	LCD_Smooth_Int( EM36_fuelP, 3, 1, 92, 132 );
}
